home *** CD-ROM | disk | FTP | other *** search
- Path: news.mcs.net!not-for-mail
- From: supercat@MCS.COM (John Payson)
- Newsgroups: comp.sys.cbm,comp.os.misc,alt.comp.hardware.homebuilt,comp.sys.apple2,comp.sys.apple2.programmer,comp.sys.atari.8bit
- Subject: Re: 6502 Multitasking OS announce
- Date: 19 Mar 1996 19:10:59 -0600
- Organization: /usr/lib/news/organi[sz]ation
- Message-ID: <4inlv3$jet@Venus.mcs.com>
- References: <4i94fs$stj@narses.hrz.tu-chemnitz.de> <4ik00v$9r@fishlab7.fsh.mtu.edu> <4im8k0$gud@gatekeeper.liffe.com> <4iml11$s69@narses.hrz.tu-chemnitz.de>
- NNTP-Posting-Host: venus.mcs.com
-
- [crossposted because I'm suggesting a technique useable on all 6502 machines]
-
- In article <4iml11$s69@narses.hrz.tu-chemnitz.de>,
- Andre Fachat <fachat@physik.tu-chemnitz.de> wrote:
- >They disable Multitasking during their critical sections. The problem
- >with the C64 is, that is doesn't have atomic test&set operations. So all
- >task switches have to be disabled to test a semaphore, or when you enter
- >a critical region.
-
- Sure the 6502 has an atomic test-and-set style operation; my preferred
- implementation [for example, to ensure that MyRoutine can only be called
- once] is...
-
- MyFlag:
- .db $FF
-
- MyRoutine:
- inc MyFlag
- bne MyRtnEnd
- .. do my routine
- MyRtnEnd:
- dec MyFlag
- rts
-
- If MyFlag is $FF when I start MyRoutine, then either the inc will happen
- before another instance of MyRoutine is started [in which case, I'll be
- able to enter] or else it won't [in which case, the second instance will
- get in]. Other variations include shift or rotate instructions but I
- don't remember the flag semantics for those; if ROR set the overflow flag
- with the old value of bit 7, that would be nice but I don't think it does.
- --
- -------------------------------------------------------------------------------
- supercat@mcs.com | "Je crois que je ne vais jamais voir... | J\_/L
- John Payson | Un animal aussi beau qu'un chat." | ( o o )
-